// app.js
App({
  onLaunch: function(){
    // 展示本地存储能力
    // const logs = wx.getStorageSync('logs') || []
    // logs.unshift(Date.now())
    // wx.setStorageSync('logs', logs)
    var that = this
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        var code = res.code;
        //console.log("code: "+code);
        wx.request({
          url: 'http://localhost:8888/account/login',
          method: 'POST',
          data: {
            code: code
          },
          header: {
            'content-type': 'application/x-www-form-urlencoded'
          },
          success: res => {
            //console.log("opennid: "+res.data.data.id);
            that.globalData.loginAccount = res.data.data.id;
          }
        })
      }
    })
  },
  globalData: {
    loginAccount: null,
    dealingId: null,
    postingId: null,
    dealingSearch: null,
    userInfo: null,
    shopId: null,
    userImg: null,
    chatWho: null,
    shopIsMine: false,
    dealIsEdit: false,
    editDealingId: null,
    postIsEdit: false,
    editPostingId: null,
    isBuying: false,
    viewBuyingId: null,
    viewPostType: 0,
  },
})